"use strict";
cc._RF.push(module, 'd4664Wf70VEzqRKF5Px3ybo', 'OPPOSDK');
// scripts/OPPOSDK.js

"use strict";

var t = require;
var e = module;
var o = exports;

var i = void 0 && (void 0).__awaiter || function (t, e, o, i) {
  return new (o || (o = Promise))(function (n, a) {
    function r(t) {
      try {
        l(i.next(t));
      } catch (e) {
        a(e);
      }
    }

    function s(t) {
      try {
        l(i["throw"](t));
      } catch (e) {
        a(e);
      }
    }

    function l(t) {
      var e;
      t.done ? n(t.value) : (e = t.value, e instanceof o ? e : new o(function (t) {
        t(e);
      })).then(r, s);
    }

    l((i = i.apply(t, e || [])).next());
  });
},
    n = void 0 && (void 0).__generator || function (t, e) {
  var o,
      i,
      n,
      a,
      r = {
    label: 0,
    sent: function sent() {
      if (1 & n[0]) throw n[1];
      return n[1];
    },
    trys: [],
    ops: []
  };
  return a = {
    next: s(0),
    "throw": s(1),
    "return": s(2)
  }, "function" == typeof Symbol && (a[Symbol.iterator] = function () {
    return this;
  }), a;

  function s(t) {
    return function (e) {
      return l([t, e]);
    };
  }

  function l(a) {
    if (o) throw new TypeError("Generator is already executing.");

    for (; r;) {
      try {
        if (o = 1, i && (n = 2 & a[0] ? i["return"] : a[0] ? i["throw"] || ((n = i["return"]) && n.call(i), 0) : i.next) && !(n = n.call(i, a[1])).done) return n;

        switch (i = 0, n && (a = [2 & a[0], n.value]), a[0]) {
          case 0:
          case 1:
            n = a;
            break;

          case 4:
            return r.label++, {
              value: a[1],
              done: !1
            };

          case 5:
            r.label++, i = a[1], a = [0];
            continue;

          case 7:
            a = r.ops.pop(), r.trys.pop();
            continue;

          default:
            if (!(n = (n = r.trys).length > 0 && n[n.length - 1]) && (6 === a[0] || 2 === a[0])) {
              r = 0;
              continue;
            }

            if (3 === a[0] && (!n || a[1] > n[0] && a[1] < n[3])) {
              r.label = a[1];
              break;
            }

            if (6 === a[0] && r.label < n[1]) {
              r.label = n[1], n = a;
              break;
            }

            if (n && r.label < n[2]) {
              r.label = n[2], r.ops.push(a);
              break;
            }

            n[2] && r.ops.pop(), r.trys.pop();
            continue;
        }

        a = e.call(t, r);
      } catch (s) {
        a = [6, s], i = 0;
      } finally {
        o = n = 0;
      }
    }

    if (5 & a[0]) throw a[1];
    return {
      value: a[0] ? a[1] : void 0,
      done: !0
    };
  }
};

Object.defineProperty(o, "__esModule", {
  value: !0
});

var a = t("GlobalUserData"),
    r = t("Hint"),
    s = t("Util"),
    l = function () {
  function t() {
    this.appId = "30550675", this.videoId = "335044", this.bannerId = "335030", this.gameBannerId = "335056", this.gamePortalId = "335065", this.nativeId1 = "335086", this.nativeId2 = "335076", this.nativeBannerId1 = "335076", this.nativeBannerId2 = "340089", this.nativeBannerId3 = "340094", this.nativeGridId = "340094", this.nativeOverViewId = "335076", this.nativeSupplyId = "340094", this.bannerAd = null, this.rewardedVideoAd = null, this.click_video = !1, this.gameBannerAd = null, this.nativeBannerObj1 = {
      nativeAd: null,
      adNode: null,
      nativeAdItem: null
    }, this.nativeBannerObj2 = {
      nativeAd: null,
      adNode: null,
      nativeAdItem: null
    }, this.nativeBannerObj3 = {
      nativeAd: null,
      adNode: null,
      nativeAdItem: null
    }, this.nativeGridObj = {
      nativeAd: null,
      adNode: null,
      nativeAdItem: null
    }, this.nativeOverViewObj = {
      nativeAd: null,
      adNode: null,
      nativeAdItem: null
    }, this.nativeHallBannerObj = {
      nativeAd: null,
      adNode: null,
      nativeAdItem: null
    }, this.nativeSupplyItem = null, this.nativeSupplyAd = null;
  }

  return Object.defineProperty(t, "instance", {
    get: function get() {
      return null == this._instance && (this._instance = new t()), this._instance;
    },
    enumerable: !1,
    configurable: !0
  }), t.prototype.init = function () {
    var t = this;
    console.log("初始化oppo"), qg.initAdService({
      appId: this.appId,
      isDebug: !0,
      success: function success() {
        console.log("qgInit success"), t.initRewardVideoAd(), t.initBanner();
      },
      fail: function fail(t) {
        console.log("init fail:" + t.code + t.msg);
      },
      complete: function complete() {
        console.log("qgInit complete");
      }
    }), a["default"].timestamp_enter_game = new Date().getTime();
  }, t.prototype.initBanner = function () {
    this.bannerAd = qg.createBannerAd({
      adUnitId: this.bannerId,
      style: {}
    }), this.bannerAd.onError(function (t) {
      console.log(JSON.stringify(t));
    });
  }, t.prototype.showBanner = function () {
    if (qg.getSystemInfoSync().platformVersion < 1051) return console.log("运行平台版本号过低，不能创建激励视频广告"), void qg.showToast({
      title: "运行平台版本号过低，请升级"
    });
    new Date().getTime() - a["default"].timestamp_enter_game < 6e4 && (a["default"].bAuditMode || !a["default"].oneMinuteInterval) || this.bannerAd && this.bannerAd.show();
  }, t.prototype.exitApplication = function () {
    qg.exitApplication({
      success: function success() {
        console.log("exitApplication success");
      },
      fail: function fail() {
        console.log("exitApplication fail");
      },
      complete: function complete() {
        console.log("exitApplication complete");
      }
    });
  }, t.prototype.hideBanner = function () {
    this.bannerAd && this.bannerAd.hide();
  }, t.prototype.initRewardVideoAd = function () {
    var t = this;
    if (qg.getSystemInfoSync().platformVersion < 1051) qg.showToast({
      title: "运行平台版本号过低，请升级"
    });else {
      this.rewardedVideoAd = qg.createRewardedVideoAd({
        adUnitId: this.videoId
      });

      var e = function e() {
        console.log("激励视频初始化成功"), t.rewardedVideoAd.offLoad(e);
      };

      this.rewardedVideoAd.onLoad(e);
    }
  }, t.prototype.showRewardVideoAd = function (t, e, o) {
    var i = this;
    if (!this.click_video) if (this.click_video = !0, qg.getSystemInfoSync().platformVersion < 1051) qg.showToast({
      title: "运行平台版本号过低，请升级"
    });else {
      this.rewardedVideoAd || (this.rewardedVideoAd = qg.createRewardedVideoAd({
        adUnitId: this.videoId
      })), this.rewardedVideoAd.load().then(function () {
        i.click_video = !1, i.rewardedVideoAd.show();
      })["catch"](function () {
        o && o(), r["default"].show("激励视频加载失败"), i.click_video = !1;
      });

      var n = function n(o) {
        i.click_video = !1, o.isEnded ? t && t() : (e && e(), r["default"].show("激励视频广告未看完，不发放奖励")), i.rewardedVideoAd.offClose(n);
      };

      this.rewardedVideoAd.offClose(n), this.rewardedVideoAd.onClose(n);
    }
  }, t.prototype.showGamePortalAd = function (t) {
    if (qg.getSystemInfoSync().platformVersionCode >= 1076) {
      var e = qg.createGamePortalAd({
        adUnitId: this.gamePortalId
      });
      e.load().then(function () {
        e.show().then(function () {
          t && t();
        })["catch"](function (t) {
          console.log("show fail with:" + t.errCode + "," + t.errMsg);
        });
      })["catch"](function (t) {
        console.log(JSON.stringify(t));
      });

      var o = function o() {
        new Date().getTime() - a["default"].timestamp_enter_game < 6e4 && a["default"].bAuditMode && console.log("审核版本1分钟内不显示banner"), e.offClose(o);
      };

      e.onShow(function () {}), e.offClose(o), e.onClose(o);
    } else r["default"].show("快应用平台版本号低于1076，暂不支持互推盒子相关 API");
  }, t.prototype.showGameBannerAd = function () {
    new Date().getTime() - a["default"].timestamp_enter_game < 6e4 && (a["default"].bAuditMode || !a["default"].oneMinuteInterval) || (console.log("展示横幅广告"), qg.getSystemInfoSync().platformVersionCode >= 1076 ? (this.gameBannerAd = qg.createGameBannerAd({
      adUnitId: this.gameBannerId
    }), this.gameBannerAd.show().then()["catch"](function (t) {
      console.log("横幅广告显示失败 " + JSON.stringify(t));
    })) : console.log("快应用平台版本号低于1076，暂不支持互推盒子相关 API"));
  }, t.prototype.hideGameBannerAd = function () {
    this.gameBannerAd && this.gameBannerAd.hide();
  }, t.prototype.reportNativeAdShow = function (t, e) {
    t && e && t.reportAdShow({
      adId: e
    });
  }, t.prototype.reportNativeAdClick = function (t, e) {
    t && e && t.reportAdClick({
      adId: e
    });
  }, t.prototype.showNativeBanner = function (t, e, o) {
    switch (void 0 === t && (t = 3), console.log("显示原生banner: " + t), t) {
      case 1:
        this.showNative(this.nativeBannerObj1, this.nativeBannerId1, "prefab/nativeBanner", !1, e, o);
        break;

      case 2:
        this.showNative(this.nativeBannerObj2, this.nativeBannerId2, "prefab/nativeBanner", !1, e, o);
        break;

      case 3:
        this.showNative(this.nativeBannerObj3, this.nativeBannerId3, "prefab/nativeBanner", !1, e, o);
    }
  }, t.prototype.clickNativeBanner = function (t) {
    switch (t) {
      case 1:
        this.reportNativeAdClick(this.nativeBannerObj1.nativeAd, this.nativeBannerObj1.nativeAdItem.adId);
        break;

      case 2:
        this.reportNativeAdClick(this.nativeBannerObj2.nativeAd, this.nativeBannerObj2.nativeAdItem.adId);
    }
  }, t.prototype.hideNativeBanner = function () {
    this.nativeBannerObj1.adNode && this.nativeBannerObj1.adNode.destroy(), this.nativeBannerObj2.adNode && this.nativeBannerObj2.adNode.destroy(), this.nativeBannerObj3.adNode && this.nativeBannerObj3.adNode.destroy(), this.nativeBannerObj1.adNode = null, this.nativeBannerObj2.adNode = null, this.nativeBannerObj3.adNode = null;
  }, t.prototype.showNativeGrid = function (t) {
    console.log("加载原生格子广告"), this.showNative(this.nativeGridObj, this.nativeGridId, "prefab/nativeGrid", !1, t);
  }, t.prototype.hideNativeGrid = function () {
    this.nativeGridObj.adNode && this.nativeGridObj.adNode.destroy(), this.nativeGridObj.adNode = null;
  }, t.prototype.clickNativeGrid = function () {
    this.nativeGridObj.adNode && this.reportNativeAdClick(this.nativeGridObj.nativeAd, this.nativeGridObj.nativeAdItem.adId);
  }, t.prototype.showNativeOverView = function (t) {
    console.log("加载结算页原生"), this.showNative(this.nativeOverViewObj, this.nativeOverViewId, "prefab/nativeOverView", !0, t);
  }, t.prototype.hideNativeOverView = function () {
    this.nativeOverViewObj.adNode && this.nativeOverViewObj.adNode.destroy(), this.nativeOverViewObj.adNode = null;
  }, t.prototype.showNativeHallBanner = function (t) {
    console.log("显示大厅页原生"), this.showNative(this.nativeHallBannerObj, this.nativeBannerId3, "prefab/nativeHallBanner", !1, t);
  }, t.prototype.hideNativeHallBanner = function () {
    this.nativeHallBannerObj.adNode && this.nativeHallBannerObj.adNode.destroy(), this.nativeHallBannerObj.adNode = null;
  }, t.prototype.clickNativeHallBanner = function () {
    this.nativeHallBannerObj.nativeAdItem && this.reportNativeAdClick(this.nativeHallBannerObj.nativeAd, this.nativeHallBannerObj.nativeAdItem.adId);
  }, t.prototype.showNative = function (t, e, o, r, l, c) {
    return void 0 === r && (r = !1), i(this, void 0, void 0, function () {
      var i,
          d,
          _h,
          _p,
          u = this;

      return n(this, function (n) {
        switch (n.label) {
          case 0:
            return new Date().getTime() - a["default"].timestamp_enter_game < 6e4 && (a["default"].bAuditMode || !a["default"].oneMinuteInterval) ? [2] : (t.nativeAd || (console.log("nativeAd：创建成功"), t.nativeAd = qg.createNativeAd({
              adUnitId: e
            })), t.nativeAd.load(), console.log("加载原生"), t.adNode ? [3, 2] : (i = t, [4, s.Util.getPrefabNode(o)]));

          case 1:
            i.adNode = n.sent(), cc.director.getScene().getChildByName("Canvas").addChild(t.adNode, 9999), n.label = 2;

          case 2:
            return r || (t.adNode.scale = cc.view.getVisibleSize().width / 1280), d = t.adNode.getComponent(cc.Sprite), t.adNode.active = !1, t.nativeAdItem && t.nativeAdItem.imgUrlList[0] && s.Util.loadImg(d, t.nativeAdItem.imgUrlList[0], function () {
              t.adNode && (t.adNode.active = !0), s.Util.is_qg() && a["default"].btnShowAdEnabled && !a["default"].bAuditMode && l && (l.active = !0), c && c(), t.adNode.getChildByName("btn_close").on("touchend", function () {
                t.adNode.destroy(), t.adNode = null;
              }), t.adNode.getChildByName("touchNode").on("touchend", function () {
                u.reportNativeAdClick(t.nativeAd, t.nativeAdItem.adId);
              });
              var e = t.adNode.getChildByName("btn_next");
              e && (r ? (e && (e.active = !0), e.on("touchend", function () {
                t.nativeAd.offLoad(_h), t.adNode.destroy(), t.adNode = null;
              })) : e && (e.active = !1));
            }), _h = function h(e) {
              t.nativeAd.offLoad(_h), console.log("原生广告加载成功", e.adList);
              var o = e.adList.pop();
              console.log(o), u.reportNativeAdShow(t.nativeAd, o.adId), s.Util.loadImg(d, o.imgUrlList[0], function () {
                t.nativeAdItem = o, t.adNode && (t.adNode.active = !0), s.Util.is_OPPO() && a["default"].btnShowAdEnabled && !a["default"].bAuditMode && l && (l.active = !0), c && c();
              }), t.adNode.getChildByName("touchNode").off("touchend"), t.adNode.getChildByName("touchNode").on("touchend", function () {
                u.reportNativeAdClick(t.nativeAd, t.nativeAdItem.adId);
              }), t.adNode.getChildByName("btn_close").off("touchend"), t.adNode.getChildByName("btn_close").on("touchend", function () {
                t.adNode.destroy(), t.adNode = null;
              });
              var i = t.adNode.getChildByName("btn_next");
              i && (r ? (i && (i.active = !0), i.on("touchend", function () {
                t.nativeAd.offLoad(_h), t.adNode.destroy(), t.adNode = null;
              })) : i && (i.active = !1));
            }, t.nativeAd.offLoad(_h), t.nativeAd.onLoad(_h), _p = function p(e) {
              console.log(e), t.nativeAd.offLoad(_h), t.nativeAd.offError(_p);
            }, t.nativeAd.onError(_p), [2];
        }
      });
    });
  }, t.prototype.showNativeSupply = function (t, e, o) {
    var i = this;
    if (e && (e.active = !1), new Date().getTime() - a["default"].timestamp_enter_game < 6e4 && a["default"].bAuditMode) console.log("审核版本1分钟内不显示banner");else {
      this.nativeSupplyAd || (this.nativeSupplyAd = qg.createNativeAd({
        adUnitId: this.nativeSupplyId
      })), this.nativeSupplyAd.load(), console.log("加载补给页原生");
      var n = t.getComponent(cc.Sprite);
      this.nativeSupplyItem && this.nativeSupplyItem.imgUrlList[0] && (s.Util.loadImg(n, this.nativeSupplyItem.imgUrlList[0], function () {
        s.Util.is_OPPO() && a["default"].btnShowAdEnabled && !a["default"].bAuditMode && e && (e.active = !0), o && o();
      }), t.getChildByName("touchNode").off("touchend"), t.getChildByName("touchNode").on("touchend", function () {
        i.reportNativeAdClick(i.nativeSupplyAd, i.nativeSupplyItem.adId);
      }));

      var r = function r(l) {
        i.nativeSupplyAd.offLoad(r), console.log("==========补给页原生广告加载成功=================");
        var c = l.adList.pop();
        console.log(c), i.reportNativeAdShow(i.nativeSupplyAd, c.adId), s.Util.loadImg(n, c.imgUrlList[0], function () {
          i.nativeSupplyItem = c, s.Util.is_OPPO() && a["default"].btnShowAdEnabled && !a["default"].bAuditMode && e && (e.active = !0), o && o();
        }), t.getChildByName("touchNode").off("touchend"), t.getChildByName("touchNode").on("touchend", function () {
          i.reportNativeAdClick(i.nativeSupplyAd, i.nativeSupplyItem.adId);
        });
      };

      this.nativeSupplyAd.offLoad(r), this.nativeSupplyAd.onLoad(r);
    }
  }, t.prototype.clickNativeSupply = function () {
    console.log("补给页面  点击查看"), console.log("this.nativeSupplyItem"), this.nativeSupplyItem && this.nativeSupplyItem.adId && this.reportNativeAdClick(this.nativeSupplyAd, this.nativeSupplyItem.adId);
  }, t.prototype.hasShortcutInstalled = function () {
    return new Promise(function (t) {
      qg.hasShortcutInstalled({
        success: function success(e) {
          console.log("拉取玩家快捷桌面状态 : " + e), t(0 != e);
        },
        fail: function fail() {
          t(!0);
        },
        complete: function complete() {}
      });
    });
  }, t.prototype.installShortCut = function (t) {
    qg.installShortcut({
      success: t,
      fail: function fail() {},
      complete: function complete() {}
    });
  }, t._instance = null, t;
}();

o["default"] = l;

cc._RF.pop();